package com.junzhiit.nengji.shop.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.shop.service.TypeService;
import com.junzhiit.nengji.shop.web.vo.ResultVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/type")
public class TypeController extends BaseController {
	
	@Autowired
	private TypeService typeService;
	
	@ApiOperation(value = "根据店铺ID查询所有分类信息,按照等级分好类")
	@RequestMapping(value = "/grading",method = RequestMethod.GET)
	public ResultVO findAllGrading(String shopId) {
		AssertUtil.notBlank(shopId, "shopId is required");
		return typeService.findAllGrading(shopId);
	}
	
	@ApiOperation(value="根据分类ID查询所有该分类的商品(非堂食)")
	@RequestMapping(value="/goods/{id}",method=RequestMethod.GET)
	public ResultVO getGoodsByType(@PathVariable String id){
		AssertUtil.notBlank(id, "id is required");
		return typeService.getGoodsByType(id);
	}
	
	@ApiOperation(value="根据分类ID查询所有该分类的商品(堂食)")
	@RequestMapping(value="/goods/eat/{id}",method=RequestMethod.GET)
	public ResultVO getSceneGoodsByType(@PathVariable String id,Integer type){
		AssertUtil.notBlank(id, "id is required");
		return typeService.getEatGoodsByType(id,type);
	}
	
}
